package com.banciyuan.bcywebview.biz.main.newdiscover.tuijian;

import android.content.Context;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.banciyuan.bcywebview.utils.common.UIUtils;

/**
 * Created by squall on 2017/3/22.
 */

public class TuijianDecoration extends RecyclerView.ItemDecoration {

    private Context mContext;

    public TuijianDecoration(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        if (parent.getChildAdapterPosition(view) % 2 == 0) {
            outRect.left = UIUtils.dip2px(4, mContext);
            outRect.right = UIUtils.dip2px(8, mContext);
        } else {
            outRect.right = UIUtils.dip2px(4, mContext);
            outRect.left = UIUtils.dip2px(8, mContext);
        }
        if (parent.getChildAdapterPosition(view) > 0) {
            outRect.top = UIUtils.dip2px(16, mContext);
        }
    }
}
